package com.trt.repository;

import com.trt.mo.MessageMO;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author tanrentao
 * @date 2021-11-24
 * @desc
 */
@Repository
public interface MessageRepository extends MongoRepository<MessageMO, String> {

    // 通过实现Repository，自定义条件查询,类似jpa
    List<MessageMO> findAllByToUserIdOrderByCreateTimeDesc(String toUserId, Pageable pageable);

    void deleteAllByFromUserIdAndToUserIdAndMsgType(String fromUserId, String toUserId, String msgType);

}
